﻿using StudentCourseUT;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;

namespace SchoolTest
{
    [TestClass()]
    public class CourseTest
    {
        private TestContext testContextInstance;

        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }
       
        [TestMethod()]
        public void CourseConstructorTestNormal()
        {
            Course course = new Course("PE");
            string expectedName = "PE";
            Assert.AreEqual(expectedName, course.Name, "Name not set correctly");
            Assert.AreNotEqual(course.Students, null, "Set not set correctly");
        }

        [TestMethod()]
        public void AddStudentNormal()
        {
            Student student = new Student("Ivan", 77777);
            Course course = new Course("PE");
            course.AddStudent(student);
            byte expectedCount = 1;
            Assert.AreEqual(course.Students.Count, expectedCount, "Add faild");
            Assert.IsTrue(course.Students.Contains(student), "Add faild");
        }

        [TestMethod()]
        [ExpectedException (typeof(ArgumentException))]
        public void AddStudentTwice()
        {
            Student student = new Student("Ivan", 77777);
            Course course = new Course("PE");
            course.AddStudent(student);
            course.AddStudent(student);
        }

        [TestMethod()]
        [ExpectedException(typeof(OverflowException))]
        public void AddStudentMoreThan30Times()
        {
            Course course = new Course("PE");
            for (int i = 0; i < 33; i++)
            {
                Student student = new Student("Ivan", 22222 + i);
                course.AddStudent(student);
            }
        }

        [TestMethod()]
        public void RemoveStudentNormal()
        {
            Student student = new Student("Ivan", 11111);
            Course course = new Course("PE");
            course.AddStudent(student);
            course.RemoveStudent(student);
            Assert.IsTrue(course.Students.Count == 0);
        }

        [TestMethod()]
        [ExpectedException(typeof(ArgumentNullException))]
        public void RemoveMissingStudent()
        {
            Student student = new Student("Ivan", 11111);
            Course course = new Course("PE");
            course.RemoveStudent(student);
        }
        
        [TestMethod()]
        public void NameTest()
        {
        }

        [TestMethod()]
        public void StudentsTest()
        {
            string name = string.Empty; // TODO: Initialize to an appropriate value
            Course target = new Course(name); // TODO: Initialize to an appropriate value
            SortedSet<Student> actual;
            actual = target.Students;
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
    }
}
